﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Compiler
{
    public class ProgramNode : INode
    {
        EbnfRuleSequence ebnfSequence;
        LexRuleSequence lexSequence;

        public ProgramNode(LexRuleSequence lexSequence, EbnfRuleSequence ebnfSequence)
        {
            this.ebnfSequence = ebnfSequence;
            this.lexSequence = lexSequence;
        }

        public void Expand(Stack<EbnfAssign> Open)
        {
            ebnfSequence.Expand(Open);
        }

        public void Convert2Grammar(Ebnf2GrammarConvertData data)
        {
            ebnfSequence.Convert2Grammar(data);
        }

        public override string ToString()
        {
            return string.Format("---Lexer----\n{0}\n\n---Parser---\n{1}\n\n", lexSequence == null? "<null>" : lexSequence.ToString(), ebnfSequence.ToString());
        }
    }
}
